<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<link rel="stylesheet" href="../bootstrap-ui/css/bootstrap.css">
<script type="text/javascript" src="../../js/jquery-1.7.2.js"></script>
<script type="text/javascript" src="js/jquery.pagination.js"></script>
<script type="text/javascript">
//模拟数据
var arr = [];
for(var i = 0; i < 100; i++){
	var date = new Date();
	arr.push({
		number: i + 1,
		_date: date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds()
	});
}
//js获取url参数
function GetRequest() {
	var url = location.search; //获取url中"?"符后的字串
	var theRequest = new Object();
	if (url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for(var i = 0; i < strs.length; i ++) {
			theRequest[strs[i].split("=")[0]]=unescape(strs[i].split("=")[1]);
		}
	}
	return theRequest;
}

$(function(){
	//模拟后端语言获取URL get参数的过程
	var Request = new Object();
	Request = GetRequest();
	var page = typeof Request['page'] == 'undefined' ? 0 : Request['page'];    //当前页数
	//渲染列表
	$('#list-content').html('');
	for(var i = 0; i < 10; i++){
		$('#list-content').append('<tr><td>' + arr[page * 10 + i].number + '</td><td>' + arr[page * 10 + i]._date + '</td></tr>');
	}
	pageinit(0,100);
});

function pageinit(page,length){
	//渲染分页
	$('#pagination').pagination(length, {
		current_page : page,
		items_per_page : 10,
		num_display_entries : 5,
		link_to : 'demo1.html?page=__id__',
		callback : function(){
			console.info("aa");
		},
		prev_text : '上一页',
		next_text : '下一页'
	});
}

</script>
</head>

<body>
<div class="row-fluid">
	<div class="span4 offset4">
		<div class="hero-unit">
			<h2>传统分页，刷新跳转</h2>
		</div>
		<table class="table table-bordered">
			<tr>
				<th style="width:20%">编号</th>
				<th>日期</th>
			</tr>
			<tbody id="list-content"></tbody>
			<tfoot>
				<tr>
					<td colspan="3">
						<div class="pagination" id="pagination" style="margin:4px 0 0 0"></div>
					</td>
				</tr>
			</tfoot>
		</table>
		<div>
			<p>本项目由 <a href="https://github.com/hooray" target="_blank">hooray</a> 创建</p>
			<p>新浪微博：<a href="http://weibo.com/hooray0905" target="_blank">@可惜我是胡尐睿丶</a></p>
		</div>
	</div>
</div>
</body>
</html>
